<template>
  <div v-loading="loading" class="content-body">
    <iframe v-if="column.url" class="dialog-iframe" :src="column.url" />
  </div>
</template>

<script>
export default {
  name: 'AppDividerV1', // 日程iframe
  props: {
    temp: {
      type: Object,
      default() {
        return {};
      }
    },
    showHeader: {
      type: Boolean,
      default: true
    },
    layout: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {
      loading: false,
      column: null,
      titleFontSize: { fontSize: '16px' },
      contentFontSize: { fontSize: '13px' },
      columnStyle: {}
    };
  },
  computed: {
    borderStyle() {
      if (this.temp.sfxsbk === true) {
        return {
          border: '1px solid #eeeeee',
          backgroundColor: this.columnStyle.mrzt,
          opacity: this.columnStyle.tmd,
          color: this.columnStyle.fontColor
        };
      }
      if (this.temp.bkyy === true) {
        return {
          boxShadow: '0 2px 4px rgba(0, 0, 0, .12)',
          backgroundColor: this.columnStyle.mrzt,
          opacity: this.columnStyle.tmd,
          color: this.columnStyle.fontColor
        };
      }
      return {
        backgroundColor: this.columnStyle.mrzt,
        opacity: this.columnStyle.tmd,
        color: this.columnStyle.fontColor
      };
    },
    liStyle() {
      const width = (100 / this.column.row).toFixed(2);
      const height = (
        100 / Math.ceil(this.column.size / this.column.row)
      ).toFixed(2);
      return { width: width + '%', height: height + '%' };
    }
  },
  watch: {
    layout: {
      handler(newName, old) {
        this.columnStyle = newName;
      },
      immediate: true, // 父组件第一次传值时，执行handler，false则第一次不执行
      deep: false // formType为对象时，设置为true，此属性监听对象发生变化
    },
    temp: {
      handler(newData, oldData) {
        if (this.showHeader) {
          const pzx = JSON.parse(newData.data.pzx);
          this.column = pzx;
          this.titleFontSize = {
            fontSize: this.column.titleFontSize + 'px',
            backgroundColor: this.columnStyle.mrzt
          };
          this.contentFontSize = {
            fontSize: this.column.contentFontSize + 'px'
          };
        } else {
          const pzx = JSON.parse(newData.pzx);
          this.column = pzx;
        }
      },
      immediate: true, // 父组件第一次传值时，执行handler，false则第一次不执行
      deep: false // formType为对象时，设置为true，此属性监听对象发生变化
    }
  }
};
</script>

<style scoped>
.content-body {
  width: 100%;
  height: 100%;
  padding: 0px 15px;
  box-sizing: border-box;
  display: flex;
  flex-flow: column nowrap;
  min-height: 50rem;
  position: relative;
  overflow: hidden;
}
.dialog-iframe {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
  right: 0px;
  border: 0;
}
</style>
